package com.svs.generator.domain;

import java.util.List;

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import com.svs.common.base.BaseEntity;
import com.svs.generator.helper.BizTableHelper;

/**
 * 业务生成表 biz_table
 * 
 * @author 杜建桥
 * @date 2019-01-31
 */
public class BizTable extends BaseEntity<BizTable> {
	private static final long serialVersionUID = 1L;

	/** 表名 */
	private String name;
	/** 生成策略 */
	private String genType;
	/** 父表名称 */
	private String parentName;
	/** 表注释 */
	private String comments;
	/** 属性名 */
	private String entityName;
	/** 生成包名 */
	private String packageName;
	/** 作者 */
	private String author;
	/** 主键类型 */
	private String idCata;
	/** 创建人 */
	private String creator;
	
	/** 同步状态 0 未创建， 1 未同步 ，2：已同步， */
	public Integer state;
	/** 是否支持导入功能 */
	private String isImport;

	public List<BizColumn> columns;

	public BizColumn primaryKey;

	public String getStateName() {
		String result = "未创建";
		if (null != state) {
			result = BizTableHelper.getStateName(state);
		}
		return result;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public void setGenType(String genType) {
		this.genType = genType;
	}

	public String getGenType() {
		return genType;
	}

	public void setParentName(String parentName) {
		this.parentName = parentName;
	}

	public String getParentName() {
		return parentName;
	}

	public void setComments(String comments) {
		this.comments = comments;
	}

	public String getComments() {
		return comments;
	}

	public void setEntityName(String entityName) {
		this.entityName = entityName;
	}

	public String getEntityName() {
		return entityName;
	}

	public void setPackageName(String packageName) {
		this.packageName = packageName;
	}

	public String getPackageName() {
		return packageName;
	}

	public void setAuthor(String author) {
		this.author = author;
	}

	public String getAuthor() {
		return author;
	}

	public void setIdCata(String idCata) {
		this.idCata = idCata;
	}

	public String getIdCata() {
		return idCata;
	}

	public void setCreator(String creator) {
		this.creator = creator;
	}

	public String getCreator() {
		return creator;
	}

	public Integer getState() {
		return state;
	}

	public void setState(Integer state) {
		this.state = state;
	}

	public List<BizColumn> getColumns() {
		return columns;
	}

	public void setColumns(List<BizColumn> columns) {
		this.columns = columns;
	}

	public BizColumn getPrimaryKey() {
		BizColumn col = null;
		int len = null != columns ? columns.size() : 0;
		for (int i = 0; i < len; i++) {
			col = columns.get(i);
			if (null != col.getIsPk() && BizTableHelper.IS_PK.equals(col.getIsPk())) {
				primaryKey = col;
				break;
			}
		}
		return primaryKey;
	}

	public void setPrimaryKey(BizColumn primaryKey) {
		this.primaryKey = primaryKey;
	}

	public String getIsImport() {
		return isImport;
	}

	public void setIsImport(String isImport) {
		this.isImport = isImport;
	}

	public String toString() {
		return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).append("name", getName())
				.append("genType", getGenType()).append("parentName", getParentName()).append("comments", getComments())
				.append("entityName", getEntityName()).append("packageName", getPackageName())
				.append("author", getAuthor()).append("idCata", getIdCata()).append("creator", getCreator())
				.append("createTime", getCreateTime()).toString();
	}
}
